﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.Config;

namespace ConAppCore.Test
{
    internal class TestConfig
    {
        public static void Test()
        {
            var ins = new ConfigIns()
            {
                ID = 1,
                RecordDeviceId = null,
                RecordDeviceName = "abcd"
            };

            string configFilePath = @"testConfig.xml";
            ConfigHelper.Save(ins, configFilePath);

            var ins22 = ConfigHelper.Load<ConfigIns>(configFilePath);
        }

    }

    public class ConfigIns : IConfig
    {
        /// <summary>
        /// 初始化默认值
        /// </summary>
        public void InitDefaultValue()
        {

        }

        /// <summary>
        /// ID
        /// </summary>
        [ConfigItem("ID", "ID", AllowNullValueElement = true)]
        public int ID { get; set; } = 1;

        /// <summary>
        /// 录音设备标识,大于等于-1时有效,与RecordDeviceName二先一,且"录音设备标识"优先级更高。
        /// </summary>
        [ConfigItem("RecordDeviceId", "录音设备标识,大于等于-1时有效,与RecordDeviceName二选一,且RecordDeviceId优先级更高", AllowNullValueElement = true)]
        public int? RecordDeviceId { get; set; } = null;

        /// <summary>
        /// 录音设备名称,与RecordDeviceName二先一,当录音设备标识为null时有效.
        /// </summary>
        [ConfigItem("RecordDeviceName", "录音设备名称,与RecordDeviceName二选一,当录音设备标识为null时有效", AllowNullValueElement = true)]
        public string RecordDeviceName { get; set; } = null;
    }
}
